﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlueFlyPhone
{

    public class AltitudeUnitConverter : IUnitConverter
    {

        public static IUnitConverter Current;

        public string DisplayUnit
        {
            get { return "m"; }

        }

        static AltitudeUnitConverter()
        {
            Current = new AltitudeUnitConverter();
        }

        double conversionFactor = 1;

        public  double ConvertToCalculationUnits(double value)
        {
            return value;
        }

        public  string ConvertToDisplayUnits(double value, int precision)
        {
            return Math.Round(value * conversionFactor, precision).ToString();
        }

    }


    public class FeetAltitudeUnitConverter : IUnitConverter
    {

        public static IUnitConverter Current;

        public string DisplayUnit
        {
            get { return "ft"; }

        }

        static FeetAltitudeUnitConverter()
        {
            Current = new FeetAltitudeUnitConverter();
        }

        double conversionFactor = 3.28084;

        public double ConvertToCalculationUnits(double value)
        {
            return value / conversionFactor;
        }

        public string ConvertToDisplayUnits(double value, int precision)
        {
            return Math.Round(value * conversionFactor, precision).ToString();
        }

    }   
        
}
